// pages/classicCase/classicCase.js
const util = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
		/* 机器人移动的位置 */
		leftLooks: 250,
		topLooks: 350,
		imageList:[
			{src:"../../images/tax-cooperation.png",id:"4",name:"税保协同"},
			{src:"../../images/shareholder-dividends.png",id:"5",name:"股东分红"},
			{src:"../../images/large-assets.png",id:"6",name:"大额资产处置所得"},
			{src:"../../images/tax-policy.png",id:"7",name:"税收优惠政策"}
		]
  },
	/* 滑动机器人 */
	imagetouchmove:function(e){
		var phoneWidth=this.data.phoneWidth;
		var phoneHeight=this.data.phoneHeight;
		var robotWidth=wx.getStorageSync("robotWidth");
		var robotHeight=wx.getStorageSync("robotHeight");
		e.touches[0].clientX=e.touches[0].clientX<0?0:e.touches[0].clientX;
		e.touches[0].clientY=e.touches[0].clientY<0?0:e.touches[0].clientY;
		e.touches[0].clientX=e.touches[0].clientX>phoneWidth-robotWidth?phoneWidth-robotWidth:e.touches[0].clientX;
		e.touches[0].clientY=e.touches[0].clientY>phoneHeight-robotHeight?phoneHeight-robotHeight:e.touches[0].clientY;
		
		this.setData({
			leftLooks: e.touches[0].clientX,
			topLooks: e.touches[0].clientY
		})
	},
	/* 跳转到搜索页面 */
	toSearch:function(){
		wx.navigateTo({
			url: "../searchPage/searchPage"
		})
	},
	/* 跳转到问题页面 */
	toQuestion:function(){
		wx.navigateTo({
			url:"../questions/questions"
		})
	},
	/* 跳转到列表页面 */
	toClassicDetail:function(e){
		wx.navigateTo({
			url: "../classicCaseDetail/classicCaseDetail?id="+e.currentTarget.dataset.id+"&name="+e.currentTarget.dataset.name
		})
	},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
		wx.setNavigationBarTitle({ title: '经典案例' }) ;
		wx.showShareMenu({  
			withShareTicket:true,
			menus: ['shareAppMessage', 'shareTimeline']
		});
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
		var _this=this;
		/* 获取手机可视区域宽高 */
		wx.getSystemInfo({
			success: function(res) {
				_this.data.phoneWidth=res.windowWidth;
				_this.data.phoneHeight=res.windowHeight;
			},
		});
  },
 	/**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
	onShareTimeline: function () {

  },
})